import { RJSFSchema, UiSchema } from '@rjsf/utils';
import { CollapseTemplate } from 'nextcae-base';
import { i18n } from '@/common/utils';
import { SelectionPickField } from '@/components/FieldTemplate/SelectionPickField';
export enum ModeType {
  OGrid = 'OGrid',
  Radial = 'Radial',
}
export const schema: RJSFSchema = {
  type: 'object',
  properties: {
    Selection: {
      type: 'object',
      title: i18n.t('Selection'),
      properties: {
        source: {
          title: i18n.t('Source'),
          type: 'array',
          ...{
            'x-options': [
              { title: '节点', const: 'node' },
              { title: '单元', const: 'element' },
              { title: '部件', const: 'face' },
            ],
          },
        },
      },
    },
    Settings: {
      type: 'object',
      title: i18n.t('Settings'),
      properties: {
        tol: {
          title: i18n.t('容差'),
          type: 'number',
          default: 0,
        },
      },
    },
    Option: {
      type: 'object',
      title: i18n.t('Option'),
      properties: {
        mergeTo: {
          title: i18n.t('合并到'),
          type: 'string',
          oneOf: [
            {
              const: 'MinId',
              title: i18n.t('最小ID'),
            },
            {
              const: 'GeomMid',
              title: i18n.t('几何中点'),
            },
            {
              const: 'MaxId',
              title: i18n.t('最大ID'),
            },
          ],
        },
        save: {
          title: i18n.t('保留'),
          type: 'string',
          default: 1,
          oneOf: [
            {
              const: 'MinId',
              title: i18n.t('最小ID'),
            },
            {
              const: 'MaxId',
              title: i18n.t('最大ID'),
            },
          ],
        },
      },
    },
  },
};

export const uiSchema: UiSchema = {
  Selection: {
    'ui:FieldTemplate': CollapseTemplate,
    'ui:layout': [1, 2],
    'ui:options': {
      label: false, // 不显示 label
    },
    source: {
      'ui:field': SelectionPickField,
      'ui:focused': true,
    },
  },
  Settings: {
    'ui:FieldTemplate': CollapseTemplate,
    'ui:layout': [1, 2],
    'ui:options': {
      label: false, // 不显示 label
    },
    tol: {
      'ui:field': 'inputField',
      'ui:type': 'number',
      'ui:options': {
        min: 0,
      },
    },
  },
  Option: {
    'ui:FieldTemplate': CollapseTemplate,
    'ui:layout': [1, 2],
    'ui:options': {
      label: false, // 不显示 label
    },
    mergeTo: {
      'ui:field': 'selectionField',
    },
    save: {
      'ui:field': 'selectionField',
    },
  },
};
